diff --git a/Prima/Classes.pm b/Prima/Classes.pm index 3d76e183..6060545c 100644 --- a/Prima/Classes.pm +++ b/Prima/Classes.pm @@ -728,7 +728,6 @@ sub profile_default region => undef, rop => rop::CopyPut, rop2 => rop::NoOper, - textColored => 0, textOutBaseline => 0, textOpaque => 0, ); diff --git a/Prima/Drawable/Metafile.pm b/Prima/Drawable/Metafile.pm index e95fb339..7677c2ef 100644 --- a/Prima/Drawable/Metafile.pm +++ b/Prima/Drawable/Metafile.pm @@ -32,7 +32,7 @@ my @props = qw( alpha antialias color backColor fillMode fillPattern lineEnd lineJoin linePattern lineWidth rop rop2 miterLimit - textOpaque textOutBaseline textColored + textOpaque textOutBaseline ); for my $prop_name (@props) { diff --git a/Prima/Drawable/Subcanvas.pm b/Prima/Drawable/Subcanvas.pm index 90f3ee88..f14e3c2f 100644 --- a/Prima/Drawable/Subcanvas.pm +++ b/Prima/Drawable/Subcanvas.pm @@ -20,7 +20,7 @@ sub profile_default { # needs to be handled with a tied hash at some point. my @easy_props = qw(color backColor fillMode fillPattern font lineEnd lineJoin linePattern lineWidth rop rop2 miterLimit - textOpaque textOutBaseline textColored + textOpaque textOutBaseline ); sub init { diff --git a/Prima/PS/Drawable.pm b/Prima/PS/Drawable.pm index 4a44960b..d93cff1a 100644 --- a/Prima/PS/Drawable.pm +++ b/Prima/PS/Drawable.pm @@ -56,7 +56,7 @@ sub save_state $self-> {save_state} = {}; $self-> {save_state}-> {$_} = $self-> $_() for qw( color backColor fillPattern lineEnd linePattern lineWidth miterLimit - rop rop2 textOpaque textColored textOutBaseline font lineJoin fillMode + rop rop2 textOpaque textOutBaseline font lineJoin fillMode ); $self->{save_state}->{fpType} = $self->{fpType}; $self-> {save_state}-> {$_} = [$self-> $_()] for qw( @@ -70,7 +70,7 @@ sub restore_state { my $self = $_[0]; for ( qw( color backColor fillPattern lineEnd linePattern lineWidth miterLimit - rop rop2 textColored textOpaque textOutBaseline font lineJoin fillMode)) { + rop rop2 textOpaque textOutBaseline font lineJoin fillMode)) { $self-> $_( $self-> {save_state}-> {$_}); } $self->{fpType} = $self->{save_state}->{fpType}; diff --git a/Prima/VB/Classes.pm b/Prima/VB/Classes.pm index 15a3cafe..c8d7bfa2 100644 --- a/Prima/VB/Classes.pm +++ b/Prima/VB/Classes.pm @@ -961,7 +961,7 @@ sub prf_types linePattern => ['linePattern'], lineWidth => ['lineWidth'], rop => ['rop', 'rop2'], - bool => ['textOutBaseline', 'textOpaque', 'fillMode', 'textColored'], + bool => ['textOutBaseline', 'textOpaque', 'fillMode'], point => ['translate', 'fillPatternOffset'], palette => ['palette'], image => ['region'], diff --git a/class/Drawable.c b/class/Drawable.c index 34a4785a..e0d9b780 100644 --- a/class/Drawable.c +++ b/class/Drawable.c @@ -39,7 +39,6 @@ Drawable_init( Handle self, HV * profile) my-> set_region ( self, pget_H ( region)); my-> set_rop ( self, pget_i ( rop)); my-> set_rop2 ( self, pget_i ( rop2)); - my-> set_textColored ( self, pget_B ( textColored)); my-> set_textOpaque ( self, pget_B ( textOpaque)); my-> set_textOutBaseline( self, pget_B ( textOutBaseline)); if ( pexist( fillPatternOffset)) @@ -679,11 +678,9 @@ Drawable_rop2( Handle self, Bool set, int rop2) } Bool -Drawable_textColored( Handle self, Bool set, Bool colored) +Drawable_is_font_colored( Handle self ) { - if (!set) return apc_gp_get_text_colored( self); - apc_gp_set_text_colored( self, colored); - return colored; + return apc_gp_is_font_colored(self); } Bool diff --git a/class/Drawable.cls b/class/Drawable.cls index 7281c712..2b3f7868 100644 --- a/class/Drawable.cls +++ b/class/Drawable.cls @@ -36,7 +36,6 @@ object Prima::Drawable ( Prima::Component) property int rop; property int rop2; property Point size; - property Bool textColored; property Bool textOpaque; property Bool textOutBaseline; property int width; @@ -70,6 +69,7 @@ object Prima::Drawable ( Prima::Component) method Color get_nearest_color( Color color); method int get_paint_state(); method SV * get_physical_palette(); + method Bool is_font_colored(); method int get_text_width( SV * text, int flags = 0, int from = 0, int len = -1); method SV * get_text_box( SV * text, int from = 0, int len = -1); method SV * render_glyph( int index, HV * profile); diff --git a/examples/fontdlg.pl b/examples/fontdlg.pl index e72ec9ac..63ddb719 100644 --- a/examples/fontdlg.pl +++ b/examples/fontdlg.pl @@ -606,7 +606,6 @@ sub create_info_window itemHeight => $ih, gridColor => cl::Back, hScroll => 1, - textColored => 1, onSelectItem => sub { my ( $self, $item, $sel) = @_; if ( defined( my $c = $charmap{$item->[0]} )) { diff --git a/include/apricot.h b/include/apricot.h index 2d0e34d0..a358595a 100644 --- a/include/apricot.h +++ b/include/apricot.h @@ -3365,9 +3365,7 @@ FV(Outline) FV(Default) #define fvScalableBitmap 0x0003 FV(ScalableBitmap) -#define fvColorOutline 0x0005 -FV(ColorOutline) -#define fvMask 0x0007 +#define fvMask 0x0003 END_TABLE(fv,UV) #undef FV @@ -3977,6 +3975,9 @@ 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); @@ -4165,9 +4166,6 @@ apc_gp_get_rop2( Handle self); extern Point* apc_gp_get_text_box( Handle self, const char * text, int len, int flags); -extern Bool -apc_gp_get_text_colored( Handle self); - extern Bool apc_gp_get_text_opaque( Handle self); @@ -4245,9 +4243,6 @@ apc_gp_set_rop( Handle self, int rop); extern Bool apc_gp_set_rop2( Handle self, int rop); -extern Bool -apc_gp_set_text_colored( Handle self, Bool colored); - extern Bool apc_gp_set_text_matrix( Handle self, Matrix matrix); diff --git a/include/unix/guts.h b/include/unix/guts.h index 8255b982..fd0ad985 100644 --- a/include/unix/guts.h +++ b/include/unix/guts.h @@ -957,7 +957,6 @@ typedef struct _drawable_sys_data unsigned sizemax_set : 1; unsigned sync_paint : 1; unsigned task_listed : 1; - unsigned text_colored : 1; unsigned title_utf8 : 1; unsigned transparent : 1; unsigned transparent_busy : 1; @@ -1016,7 +1015,7 @@ typedef struct _PaintState XGCValues gcv; } nonpaint; int alpha, fill_mode, n_dashes, rop, rop2; - Bool antialias, text_opaque, text_baseline, null_hatch, text_colored; + Bool antialias, text_opaque, text_baseline, null_hatch; Point fill_pattern_offset; Handle fill_image; FillPattern fill_pattern; diff --git a/include/win32/win32guts.h b/include/win32/win32guts.h index a3dc4f7d..05dc8552 100644 --- a/include/win32/win32guts.h +++ b/include/win32/win32guts.h @@ -169,7 +169,6 @@ typedef struct _HandleOptions_ { unsigned aptEnabled : 1; // enabled flag unsigned aptTextOpaque : 1; // gp text drawing flag unsigned aptTextOutBaseline : 1; // gp text drawing flag - unsigned aptTextColored : 1; // draw color font with colors unsigned aptWinPosDetermined : 1; // 0 when size is set, but position is not unsigned aptOnTop : 1; // HWND_TOPMOST is set unsigned aptLayered : 1; // WS_EX_LAYERED @@ -377,6 +376,7 @@ typedef struct _DCFont HFONT hfont; void * dw_colorface; Bool dw_checked; + int8_t dw_is_color_font; } DCFont, *PDCFont; #define DCO_PEN 0 @@ -708,7 +708,7 @@ extern PList dnd_clipboard_get_formats(); extern Bool dwrite_font_init(void); extern void dwrite_font_done(void); extern void dwrite_free_face(void *face); -extern Bool dwrite_logfont_colored( LOGFONTW *lf ); +extern Bool dwrite_is_font_colored( Handle self, PDCFont dcfont); extern Bool dwrite_color_text_out(Handle self, PDCFont dc, PGlyphsOutRec t, int x, int y); extern void dpi_change(void); extern char * err_msg( DWORD errId, char * buffer); diff --git a/unix/graphics.c b/unix/graphics.c index b0ac964d..d543b6f6 100644 --- a/unix/graphics.c +++ b/unix/graphics.c @@ -1513,7 +1513,7 @@ apc_gp_get_text_opaque( Handle self) Bool apc_gp_get_text_colored( Handle self) { - return X(self)-> flags. text_colored ? true : false; + return false; } Bool @@ -1804,13 +1804,6 @@ apc_gp_set_rop2( Handle self, int rop) return true; } -Bool -apc_gp_set_text_colored( Handle self, Bool colored) -{ - X(self)-> flags. text_colored = !!colored; - return true; -} - Bool apc_gp_set_text_opaque( Handle self, Bool opaque) { @@ -1863,7 +1856,6 @@ apc_gp_push(Handle self, GCStorageFunction * destructor, void * user_data, unsig state->rop2 = XX->rop2; state->text_baseline = XX->flags.base_line; state->text_opaque = XX->flags.opaque; - state->text_colored = XX->flags.text_colored; if ( state-> in_paint ) { state->paint.fore = XX->fore; state->paint.back = XX->back; @@ -1923,7 +1915,6 @@ apc_gp_pop( Handle self, void * user_data) XX->rop2 = state->rop2; XX->flags. base_line = state->text_baseline; XX->flags. opaque = state->text_opaque; - XX->flags. text_colored= state->text_colored; if ( state-> in_paint ) { XX->fore = state->paint.fore; XX->back = state->paint.back; diff --git a/win32/dwfont.c b/win32/dwfont.c index 62d70ec0..a6235f19 100644 --- a/win32/dwfont.c +++ b/win32/dwfont.c @@ -7,6 +7,8 @@ #include #include +#include "DeviceBitmap.h" +#include "Image.h" #include "Widget.h" #ifdef __cplusplus @@ -68,20 +70,35 @@ dwrite_font_done(void) } Bool -dwrite_logfont_colored( LOGFONTW *lf ) +dwrite_is_font_colored( Handle self, PDCFont dcfont) { HRESULT hr; + LOGFONTW lf; IDWriteFont2 *font; Bool ok = false; - if (!dw_ok) return ok; + if (!dw_ok) return false; - hr = gdi->lpVtbl->CreateFontFromLOGFONT(gdi, lf, (IDWriteFont**) &font); - if ( hr != S_OK ) + if ( + dcfont->dw_is_color_font < 0 || + ( is_apt(aptDeviceBitmap) && ((PDeviceBitmap)self)->type == dbtBitmap) || + ( is_apt(aptImage) && ((PImage)self)-> type == imBW ) + ) + return false; + else if ( dcfont->dw_is_color_font > 0 ) + return true; + + font_font2logfont( &dcfont->font, &lf); + + hr = gdi->lpVtbl->CreateFontFromLOGFONT(gdi, &lf, (IDWriteFont**) &font); + if ( hr != S_OK ) { + dcfont->dw_is_color_font = -1; apiHErrRet(hr); + } if ( font->lpVtbl->IsColorFont(font)) ok = true; + dcfont->dw_is_color_font = ok ? 1 : -1; font->lpVtbl->Release(font); return ok; diff --git a/win32/gp.c b/win32/gp.c index 55b5d31c..affb3bdd 100644 --- a/win32/gp.c +++ b/win32/gp.c @@ -1284,7 +1284,6 @@ apc_gp_push(Handle self, GCStorageFunction * destructor, void * user_data, unsig state->common.font = var font; state->common.text_out_baseline = is_apt( aptTextOutBaseline); state->common.text_opaque = is_apt( aptTextOpaque); - state->common.text_colored = is_apt( aptTextColored); if ( var fillPatternImage ) protect_object( state->fill_image = var fillPatternImage ); return true; @@ -1362,7 +1361,6 @@ apc_gp_pop( Handle self, void * user_data) var fillPatternImage = state-> fill_image; apt_assign(aptTextOutBaseline, state->common.text_out_baseline); apt_assign(aptTextOpaque, state->common.text_opaque); - apt_assign(aptTextColored, state->common.text_colored); if ( sys alpha_arena_palette ) { free(sys alpha_arena_palette); sys alpha_arena_palette = NULL; diff --git a/win32/stock.c b/win32/stock.c index 2af9c01b..5f1539e4 100644 --- a/win32/stock.c +++ b/win32/stock.c @@ -1213,7 +1213,6 @@ typedef struct _FEnumStruc int fType; Bool useWidth; Bool wantOutline; - Bool wantColored; Bool useVector; Bool usePitch; Bool forceSize; @@ -1248,11 +1247,6 @@ fep( ENUMLOGFONTEXW FAR *e, NEWTEXTMETRICEXW FAR *t, DWORD type, LPARAM _es) if ( font-> vector != fvDefault) { int src = (( t-> ntmTm. tmPitchAndFamily & ( TMPF_VECTOR | TMPF_TRUETYPE)) ? fvOutline : fvBitmap); - if ( es-> wantColored ) { - if ( src == fvOutline && !dwrite_logfont_colored( &e->elfLogFont )) - return 1; - src = fvColorOutline; - } if ( src != font-> vector) return 1; // so this font cannot be selected due quality pickup failure } @@ -1346,7 +1340,6 @@ font_font2gp_internal( PFont font, Point res, Bool forceSize, HDC theDC) HDC dc = theDC ? theDC : dc_alloc(); Bool useNameSubplacing = false; LOGFONTW elf; - Font savefont = *font; if ( !dc) return fvBitmap; @@ -1354,11 +1347,9 @@ font_font2gp_internal( PFont font, Point res, Bool forceSize, HDC theDC) es. resValue = es. heiValue = es. widValue = INT_MAX; es. useWidth = font-> width != 0; es. useVector = font->vector != fvDefault; - es. wantColored = font->vector == fvColorOutline; es. wantOutline = (font-> vector == fvDefault && fabs(font-> direction) > 0.0001) || - font->vector == fvOutline || - font->vector == fvColorOutline; + font->vector == fvOutline; es. usePitch = font-> pitch != fpDefault; es. res = res; es. forceSize = forceSize; @@ -1480,21 +1471,12 @@ font_font2gp_internal( PFont font, Point res, Bool forceSize, HDC theDC) font_logfontname2font( &lpf, font); font_textmetric2font( &tm, font, true); if ( have_otm ) font_otm2font( &otm, font ); - if ( es.wantColored && font->vector == fvOutline && dwrite_logfont_colored(&es.lf)) - font-> vector = fvColorOutline; strlcpy( font-> family, es. family, LF_FULLFACESIZE); font-> is_utf8.family = es.is_utf8_family; out( font->vector ); } } - // if colored request is too strict - if ( es.wantColored && es.count == 0 ) { - *font = savefont; - font-> vector = fvOutline; - return font_font2gp_internal( font, res, forceSize, theDC); - } - // if strict match not found, use subplacing if ( useNameSubplacing && recursiveFFPitch == 0) { @@ -1642,8 +1624,6 @@ fep2( ENUMLOGFONTEXW FAR *e, NEWTEXTMETRICEXW FAR *t, DWORD type, LPARAM _f) if ( !fm) return 1; memset( fm, 0, sizeof(Font)); font_textmetric2font(( TEXTMETRICW*) &t-> ntmTm, fm, false); - if ( fm->vector == fvOutline && dwrite_logfont_colored(&e->elfLogFont)) - fm-> vector = fvColorOutline; if ( f-> hash) { /* multi-encoding format */ char ** enc = (char**) fm-> encoding; unsigned char * shift = (unsigned char*)enc + sizeof(char *) - 1; @@ -2072,7 +2052,6 @@ hwnd_enter_paint( Handle self) apc_gp_set_alpha( self, sys alpha); apc_gp_set_antialias( self, is_apt( aptGDIPlus)); - apc_gp_set_text_colored( self, is_apt( aptTextColored)); apc_gp_set_text_opaque( self, is_apt( aptTextOpaque)); apc_gp_set_text_out_baseline( self, is_apt( aptTextOutBaseline)); apc_gp_set_fill_mode( self, sys fill_mode); diff --git a/win32/text.c b/win32/text.c index 7c519483..4f973b53 100644 --- a/win32/text.c +++ b/win32/text.c @@ -4,8 +4,6 @@ #include #include "guts.h" #include "win32\win32guts.h" -#include "DeviceBitmap.h" -#include "Image.h" #include "Widget.h" #ifdef __cplusplus @@ -504,7 +502,7 @@ apc_gp_text_out( Handle self, const char * text, int x, int y, int len, int flag HDC ps = sys ps; int bk = GetBkMode( ps); int opa = is_apt( aptTextOpaque) ? OPAQUE : TRANSPARENT; - Bool use_path, want_color = false; + Bool use_path; int div = 32768L / (var font. maximalWidth ? var font. maximalWidth : 1); if ( div <= 0) div = 1; @@ -515,12 +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 ( is_apt( aptTextColored )) - want_color = !( - ( is_apt(aptDeviceBitmap) && ((PDeviceBitmap)self)->type == dbtBitmap) || - ( is_apt(aptImage) && ((PImage)self)-> type == imBW ) - ); - if ( want_color || sys alpha < 255 ) + if ( sys alpha < 255 || apc_gp_is_font_colored(self)) return shaped_text_out( self, text, x, y, len, flags); if ( flags & toUTF8 ) { @@ -675,7 +668,7 @@ apc_gp_glyphs_out( Handle self, PGlyphsOutRec t, int x, int y) FontContext fc; float fxx, fyy; NPoint cs = CDrawable(self)->trig_cache(self); - Bool want_color = false; + Bool want_color; select_world_transform(self, true); SHIFT_XY(x,y); @@ -684,6 +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); if ( use_path ) { STYLUS_USE_BRUSH; BeginPath(ps); @@ -700,12 +694,6 @@ apc_gp_glyphs_out( Handle self, PGlyphsOutRec t, int x, int y) savelen = t->len; font_context_init(&fc, self, t); - if ( is_apt( aptTextColored )) - want_color = !( - ( is_apt(aptDeviceBitmap) && ((PDeviceBitmap)self)->type == dbtBitmap) || - ( is_apt(aptImage) && ((PImage)self)-> type == imBW ) - ); - while (( t-> len = font_context_next(&fc)) > 0 ) { int advance = 0; @@ -2160,18 +2148,10 @@ apc_gp_get_text_out_baseline( Handle self) } Bool -apc_gp_get_text_colored( Handle self) +apc_gp_is_font_colored( Handle self) { objCheck false; - return is_apt( aptTextColored); -} - -Bool -apc_gp_set_text_colored( Handle self, Bool colored) -{ - objCheck false; - apt_assign( aptTextColored, colored); - return true; + return dwrite_is_font_colored(self, sys dc_font); } Bool