Skip to content

Commit

Permalink
update missing merge from write
Browse files Browse the repository at this point in the history
  • Loading branch information
dk committed Nov 24, 2024
1 parent b8c6f51 commit bb8e7dc
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 20 deletions.
2 changes: 1 addition & 1 deletion class/Drawable.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ Drawable_rop2( Handle self, Bool set, int rop2)
Bool
Drawable_is_font_colored( Handle self )
{
return apc_gp_is_font_colored(self);
return apc_font_is_colored(self);
}

Bool
Expand Down
6 changes: 3 additions & 3 deletions include/apricot.h
Original file line number Diff line number Diff line change
Expand Up @@ -3975,9 +3975,6 @@ apc_gp_bars( Handle self, int nr, Rect *rr);
extern Bool
apc_gp_can_draw_alpha( Handle self);

extern Bool
apc_gp_is_font_colored( Handle self);

extern Bool
apc_gp_clear( Handle self, int x1, int y1, int x2, int y2);

Expand Down Expand Up @@ -4333,6 +4330,9 @@ apc_font_get_text_shaper( Handle self, int *type);
extern Byte*
apc_font_get_glyph_bitmap( Handle self, uint16_t index, unsigned int flags, PPoint offset, PPoint size, int *advance, int *type);

extern Bool
apc_font_is_colored( Handle self);

extern PFont
apc_fonts( Handle self, const char *facename, const char *encoding, int *retCount);

Expand Down
7 changes: 7 additions & 0 deletions include/unix/guts.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ typedef struct CachedFont {
XFont id;
PRotatedFont rotated;

int8_t has_colors;
#ifdef USE_FONTQUERY
FT_Face ft_face;
FcCharSet *fc_charset;
Expand Down Expand Up @@ -1650,6 +1651,9 @@ prima_xft_mapper_query_ranges(PFont font, int * count, unsigned int * flags);
extern Byte*
prima_xft_get_glyph_bitmap( Handle self, uint16_t index, unsigned int flags, PPoint offset, PPoint size, int *advance);

extern Bool
prima_xft_is_font_colored(Handle self);

#endif

extern Bool
Expand Down Expand Up @@ -1939,6 +1943,9 @@ prima_ft_get_glyph_outline( FT_Face face, FT_UInt ft_index, FT_Int32 ft_flags, i
extern Byte*
prima_ft_get_glyph_bitmap( FT_Face face, FT_UInt index, FT_Int32 flags, PPoint offset, PPoint size, int *advance);

extern Bool
prima_ft_is_font_colored( FT_Face face);

extern Bool
prima_ft_text_shaper_harfbuzz( FT_Face face, PTextShapeRec r);

Expand Down
11 changes: 8 additions & 3 deletions unix/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,17 @@ x_error_handler( Display *d, XErrorEvent *ev)
return 0;
}

#ifdef NEED_X11_EXTENSIONS_XRENDER_H
#ifdef HAVE_X11_EXTENSIONS_XRENDER_H
if ( ev-> request_code == guts. xft_xrender_major_opcode &&
ev-> request_code > 127 &&
ev-> error_code == BadLength)
/* Xrender large polygon request failed */
ev-> error_code == BadLength) {
/* Xrender large polygon request failed,
or colored glyphs over an older X11 server
*/
if ( guts. xft_disable_large_fonts )
return 1;
guts. xft_disable_large_fonts = 1;
}
#endif

#ifdef HAVE_X11_EXTENSIONS_XCOMPOSITE_H
Expand Down
33 changes: 32 additions & 1 deletion unix/font.c
Original file line number Diff line number Diff line change
Expand Up @@ -821,11 +821,42 @@ apc_font_get_glyph_bitmap( Handle self, uint16_t index, unsigned int flags, PPoi
return prima_corefont_get_glyph_bitmap(self, index, flags & ggoMonochrome, offset, size, advance);
}

Bool
apc_font_is_colored( Handle self)
{
DEFXX;
PCachedFont f = XX->font;
if (
f->has_colors < 0 ||
( XT_IS_DBM(XX) && XT_IS_BITMAP(XX)) ||
( XT_IS_IMAGE(XX) && ((PImage)self)-> type == imBW )
)
return false;
else if ( f->has_colors > 0 )
return true;

#ifdef USE_FONTQUERY
if ( is_opt(optInFontQuery) ) {
return false; /* XXX because colored bitmaps are not supported */
}
#endif

#ifdef USE_XFT
if ( f->xft ) {
Bool ok = prima_xft_is_font_colored(self);
f->has_colors = ok ? 1 : -1;
return ok;
}
#endif

return false;
}

Bool
apc_gp_set_text_matrix( Handle self, Matrix matrix)
{
PFont f = & PDrawable(self)->font;
if (f->undef.height &&f->undef.size) /* too early */
if (f->undef.height && f->undef.size) /* too early */
return true;
return apc_gp_set_font( self, f);
}
Expand Down
19 changes: 19 additions & 0 deletions unix/freetype.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,5 +382,24 @@ prima_ft_detail_tt_font( FT_Face face, PFont font, float mul)
font->width = 1;
}

Bool
prima_ft_is_font_colored( FT_Face face)
{
#if defined(TTAG_COLR) && defined(TTAG_CPAL)
FT_Int a,b,c;
FT_ULong l1 = 0, l2 = 0;

FT_Library_Version(ft_library,&a,&b,&c);
if ( a < 2 || ( a == 2 && b < 10 )) /* CPAL/COLR only supported in 2.10 */
return false;
return
(FT_Load_Sfnt_Table(face, TTAG_COLR, 0, NULL, &l1) == 0) &&
(FT_Load_Sfnt_Table(face, TTAG_CPAL, 0, NULL, &l2) == 0)
;
#else
return false;
#endif
}

#endif

6 changes: 0 additions & 6 deletions unix/graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -1510,12 +1510,6 @@ apc_gp_get_text_opaque( Handle self)
return X(self)-> flags. opaque ? true : false;
}

Bool
apc_gp_get_text_colored( Handle self)
{
return false;
}

Bool
apc_gp_get_text_out_baseline( Handle self)
{
Expand Down
4 changes: 2 additions & 2 deletions unix/render.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ typedef struct {

static Pen pen;

#ifdef NEED_X11_EXTENSIONS_XRENDER_H
#ifdef HAVE_X11_EXTENSIONS_XRENDER_H
/* piece of Xrender guts */
typedef struct _XExtDisplayInfo {
struct _XExtDisplayInfo *next;
Expand Down Expand Up @@ -62,7 +62,7 @@ prima_init_xrender_subsystem(char * error_buf, Bool disable_argb32)

if ( !guts. render_extension ) return true;

#ifdef NEED_X11_EXTENSIONS_XRENDER_H
#ifdef HAVE_X11_EXTENSIONS_XRENDER_H
{ /* snatch error code from xrender guts */
XExtDisplayInfo *info = XRenderFindDisplay( DISP);
if ( info && info-> codes)
Expand Down
13 changes: 13 additions & 0 deletions unix/xft.c
Original file line number Diff line number Diff line change
Expand Up @@ -1427,6 +1427,19 @@ prima_xft_get_glyph_bitmap( Handle self, uint16_t index, unsigned int flags, PPo
return ret;
}

Bool
prima_xft_is_font_colored( Handle self )
{
DEFXX;
Bool ret;
FT_Face face;
if ( !( face = XftLockFace( XX->font->xft)))
return false;
ret = prima_ft_is_font_colored(face);
XftUnlockFace(XX->font->xft);
return ret;
}

unsigned long *
prima_xft_mapper_query_ranges(PFont font, int * count, unsigned int * flags)
{
Expand Down
8 changes: 4 additions & 4 deletions win32/text.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ apc_gp_text_out( Handle self, const char * text, int x, int y, int len, int flag
their geometrical limits. */
if ( len > div) len = div;

if ( sys alpha < 255 || apc_gp_is_font_colored(self))
if ( sys alpha < 255 || apc_font_is_colored(self))
return shaped_text_out( self, text, x, y, len, flags);

if ( flags & toUTF8 ) {
Expand Down Expand Up @@ -677,7 +677,7 @@ apc_gp_glyphs_out( Handle self, PGlyphsOutRec t, int x, int y)
if ( t->len > 8192 ) t->len = 8192;
use_path = GetROP2( sys ps) != R2_COPYPEN;
use_alpha = sys alpha < 255;
want_color = t->fonts ? true : apc_gp_is_font_colored(self);
want_color = t->fonts ? true : apc_font_is_colored(self);
if ( use_path ) {
STYLUS_USE_BRUSH;
BeginPath(ps);
Expand Down Expand Up @@ -2217,7 +2217,7 @@ apc_gp_get_text_out_baseline( Handle self)
}

Bool
apc_gp_is_font_colored( Handle self)
apc_font_is_colored( Handle self)
{
objCheck false;
return dwrite_is_font_colored(self, sys dc_font);
Expand Down Expand Up @@ -2301,7 +2301,7 @@ apc_font_get_glyph_bitmap( Handle self, uint16_t index, unsigned int flags, PPoi
if (
!(flags & ggoMonochrome) &&
(flags & ggoARGB) &&
apc_gp_is_font_colored
apc_font_is_colored
) {
//dwrite_draw_bitmap( self, index, *size, *offset);
}
Expand Down

0 comments on commit bb8e7dc

Please sign in to comment.