diff --git a/src/Graphics/Fonts/font.cpp b/src/Graphics/Fonts/font.cpp index 37b77c38a..f82874c2c 100644 --- a/src/Graphics/Fonts/font.cpp +++ b/src/Graphics/Fonts/font.cpp @@ -558,13 +558,10 @@ font_rep::make_rubber_font (font fn) { return rubber_stix_font (fn); else if (occurs ("mathlarge=", name) || occurs ("mathrubber=", name)) return fn; - // else if (has_poor_rubber && fn->type == FONT_TYPE_UNICODE) { - // cout << "TeXmacs] warning: using poor rubber font for " << fn->res_name - // << "\n"; - // return poor_rubber_font (fn); - // } + else if (has_poor_rubber && fn->type == FONT_TYPE_UNICODE) { + return poor_rubber_font (fn); + } else if (fn->type == FONT_TYPE_UNICODE) { - cout << "TeXmacs] warning: using unicode rubber font for " << fn->res_name << "\n"; return rubber_unicode_font (fn); } else return fn; diff --git a/src/Graphics/Fonts/smart_font.cpp b/src/Graphics/Fonts/smart_font.cpp index c13a44a42..a5952409f 100644 --- a/src/Graphics/Fonts/smart_font.cpp +++ b/src/Graphics/Fonts/smart_font.cpp @@ -808,9 +808,9 @@ smart_font_rep::advance (string s, int& pos, string& r, int& nr) { if (N (fn) <= nr || is_nil (fn[nr])) initialize_font (nr); if (sm->fn_rewr[nr] != REWRITE_NONE) r= rewrite (r, sm->fn_rewr[nr]); // if (DEBUG_VERBOSE) { - debug_fonts << "Physical font of [" << r << "]" - << "[" << herk_to_utf8 (r) << "][" << cork_to_utf8 (r) << "]" - << " is " << fn[nr]->res_name << LF; + debug_fonts << "Physical font of [" << r << "]" + << "[" << herk_to_utf8 (r) << "][" << cork_to_utf8 (r) << "]" + << " is " << fn[nr]->res_name << LF; // } } @@ -855,8 +855,8 @@ is_wanted (string c, string family, array rules, array given) { int smart_font_rep::resolve (string c, string fam, int attempt) { // if (DEBUG_VERBOSE) { - debug_fonts << "Resolve " << c << " in fam " << fam << " mfam " << mfam - << ", attempt " << attempt << LF; + debug_fonts << "Resolve " << c << " in fam " << fam << " mfam " << mfam + << ", attempt " << attempt << LF; // } array a= trimmed_tokenize (fam, "="); if (N (a) >= 2) { @@ -963,10 +963,12 @@ smart_font_rep::resolve (string c, string fam, int attempt) { initialize_font (nr); return sm->add_char (key, c); } + if (starts (c, " emu_names= emu_font_names (); for (int i= 0; i < N (emu_names); i++) if (virtually_defined (c, emu_names[i])) { + cout << "Emulate " << c << " in " << emu_names[i] << LF; tree key= tuple ("emulate", emu_names[i]); int nr = sm->add_font (key, REWRITE_NONE); initialize_font (nr); @@ -1013,7 +1015,7 @@ extern bool has_poor_rubber; int smart_font_rep::resolve_rubber (string c, string fam, int attempt) { - cout << "Rubber " << c << ", " << fam << ", " << attempt << LF; + cout << "Resolve Rubber " << c << ", " << fam << ", " << attempt << LF; if (is_italic_font (mfam)) return -1; int l= search_forwards ("-", 0, c) + 1; int r= search_forwards ("-", l, c); @@ -1021,40 +1023,14 @@ smart_font_rep::resolve_rubber (string c, string fam, int attempt) { string ss = c (l, r); string goal= ss; if (N (goal) != 1) goal= "<" * goal * ">"; + if (starts (c, "") { tree key= tuple ("ignore"); int nr = sm->add_font (key, REWRITE_IGNORE); initialize_font (nr); return sm->add_char (key, c); } -// if (starts (c, "") r= "<#302>"; -// else if (r == "") r= "<#303>"; -// else if (r == "") r= "<#30C>"; -// else if (r == "") r= "<#305>"; -// else if (r == "") r= "<#20D7>"; -// else if (r == "") r= "<#306>"; -// else if (r == "") r= "<#311>"; -// else -// #endif -// if (r == "") r= "<#23DD>"; -// else if (r == "") r= "<#23DD>"; -// else if (r == "") r= "<#23DF>"; -// else if (r == "") r= "<#23DF>"; -// else if (r == "") r= "<#23B5>"; -// else if (r == "") r= "<#23B5>"; -// else if (r == "") r= "<#23DC>"; -// else if (r == "") r= "<#23DC>"; -// else if (r == "") r= "<#23DE>"; -// else if (r == "") r= "<#23DE>"; -// else if (r == "") r= "<#23B4>"; -// else if (r == "") r= "<#23B4>"; -// goal= r; -// } if (has_poor_rubber) { - cout << "Poor rubber " << c << ", " << fam << ", " << attempt << LF; if (goal == "") goal= "|"; // FIXME: better goal? if (goal == "<||>" || goal == "") goal= "|"; if (goal == "" || goal == "" || goal == "" || @@ -1069,13 +1045,14 @@ smart_font_rep::resolve_rubber (string c, string fam, int attempt) { goal == "" || goal == "") goal= "]"; } + cout << "Goal is " << goal << LF; int bnr= resolve (goal, main_family (fam), attempt); if (bnr >= 0 && bnr < N (fn) && !is_nil (fn[bnr])) { tree key= tuple ("rubber", as_string (bnr)); int nr = sm->add_font (key, REWRITE_NONE); initialize_font (nr); - // cout << fn[nr]->res_name << " supports " << c - // << "? " << fn[nr]->supports (c) << LF; + cout << fn[nr]->res_name << " supports " << c << "? " + << fn[nr]->supports (c) << LF; if (fn[nr]->supports (c)) return sm->add_char (key, c); } return -1; @@ -1182,7 +1159,7 @@ smart_font_rep::resolve (string c) { if (is_rubber (c)) { nr= resolve_rubber (c, a[i], attempt); if (nr >= 0) { - // cout << "Found " << c << " in poor-rubber\n"; + cout << "Found " << c << " in poor-rubber\n"; return nr; } } @@ -1355,15 +1332,7 @@ static string empty_string (""); bool smart_font_rep::supports (string c) { - if (starts (c, "supports (c); - return res; - } + (void) c; return true; } diff --git a/src/Graphics/Fonts/smart_font.hpp b/src/Graphics/Fonts/smart_font.hpp index baf09ef3a..86cbd7b64 100644 --- a/src/Graphics/Fonts/smart_font.hpp +++ b/src/Graphics/Fonts/smart_font.hpp @@ -118,8 +118,8 @@ struct smart_font_rep : font_rep { void initialize_font (int nr); int adjusted_dpi (string fam, string var, string ser, string sh, int att); - font make_rubber_font(font base) override; - + font make_rubber_font (font base) override; + bool supports (string c); void get_extents (string s, metric& ex); void get_xpositions (string s, SI* xpos); diff --git a/src/Plugins/Freetype/rubber_unicode_font.cpp b/src/Plugins/Freetype/rubber_unicode_font.cpp index 912bf06e9..243cdfafb 100644 --- a/src/Plugins/Freetype/rubber_unicode_font.cpp +++ b/src/Plugins/Freetype/rubber_unicode_font.cpp @@ -9,7 +9,6 @@ * in the root directory or . ******************************************************************************/ -#include "unicode_font.hpp" #include "Freetype/tt_face.hpp" #include "analyze.hpp" #include "array.hpp" @@ -17,8 +16,10 @@ #include "font.hpp" #include "hashmap.hpp" #include "lolly/data/numeral.hpp" +#include "observer.hpp" #include "string.hpp" #include "translator.hpp" +#include "unicode_font.hpp" #include #include using lolly::data::as_hexadecimal; @@ -94,15 +95,10 @@ rubber_unicode_font_rep::rubber_unicode_font_rep (string name, font base2, } if (base->math_type == MATH_TYPE_OPENTYPE) { - cout << "rubber for open type: " << base->res_name << LF; - big_flag = true; - big_sums = true; + cout << "rubber for unicode font with opentype: " << base->res_name << LF; + big_flag= true; + big_sums= true; } - - // if (!is_nil (math_face) && !is_nil (math_face->math_table)) { - // big_flag= true; - // big_sums= true; - // } } font @@ -184,57 +180,66 @@ normalized_cork_to_utf8 (string s) { bool rubber_unicode_font_rep::search_font_sub_bis (string s, string& rew, int& nr) { // look up opentype math table - cout << "search_font_sub_bis for " << s << LF; string r; string rg; int var= 0; - bool hor= false; // horizontal or vertical + bool ver= true; // verizontal or vertical, default is vertical rew = s; nr = 0; + // large,big,wide + // left,right,mid? + if (starts (s, " " << r << ", " << rg << ", " << var << LF; + cout << "search_font_sub_bis for " << s << " -> " << r << ", " << rg << ", " + << var << LF; if (r == "") return false; - string uu = normalized_cork_to_utf8 ("<" * r * ">"); - int j = 0; - unsigned int u = decode_from_utf8 (uu, j); + string uu= N (r) > 1 ? strict_cork_to_utf8 ("<" * r * ">") : r; + + int j= 0; + unsigned int u= decode_from_utf8 (uu, j); + cout << "unicode " << uu << " -> " << lolly::data::to_hex (u) << LF; + unsigned int glyphID= ft_get_char_index (math_face->ft_face, u); cout << "search_font_sub_bis for " << u << " -> " << glyphID << LF; - auto variant= hor ? math_face->math_table->hor_glyph_variants - : math_face->math_table->ver_glyph_variants; + auto variant= ver ? math_face->math_table->ver_glyph_variants + : math_face->math_table->hor_glyph_variants; if (variant->contains (glyphID)) { cout << "Variant for " << uu << " -> " << glyphID << LF; auto& v= variant (glyphID); if (var < N (v)) { auto res= v[var]; - rew = "<@" * as_hexadecimal (res, 4) * ">"; - nr = 0; + // use <@XXXX> for native glyph id + rew= "<@" * as_hexadecimal (res, 4) * ">"; + nr = 0; cout << "Variant for " << uu << " -> " << glyphID << " -> " << rew << LF; return true; } @@ -318,7 +323,7 @@ rubber_unicode_font_rep::search_font_cached (string s, string& rew) { // try opentype math table int nr= 0; cout << "try opentype for " << s << " with font " << res_name << LF; - if(is_nil (math_face)) { + if (is_nil (math_face)) { cout << "no math face" << LF; } if (!is_nil (math_face) && !is_nil (math_face->math_table) && @@ -348,6 +353,8 @@ rubber_unicode_font_rep::search_font (string& s) { bool rubber_unicode_font_rep::supports (string s) { + cout << "test support for " << s << LF; + if (starts(s, "") || ends (s, "-2>"))) { string r= s (5, N (s) - 3); if (ends (r, "lim")) r= r (0, N (r) - 3); @@ -432,7 +439,7 @@ rubber_unicode_font_rep::draw_fixed (renderer ren, string s, SI x, SI y, font rubber_unicode_font_rep::magnify (double zoomx, double zoomy) { cout << "magnify for " << base->res_name << LF; - return rubber_unicode_font (base->magnify (zoomx, zoomy)); + return rubber_unicode_font (base->magnify (zoomx, zoomy), math_face); } glyph @@ -521,6 +528,5 @@ font rubber_unicode_font (font base, tt_face face) { cout << "call rubber_unicode_font with math face " << base->res_name << LF; string name= "rubberunicode[" * base->res_name * "]"; - return make (font, name, tm_new (name, base, - face)); + return make (font, name, tm_new (name, base, face)); } diff --git a/src/Plugins/Freetype/unicode_font.cpp b/src/Plugins/Freetype/unicode_font.cpp index 192e4a195..7bdc1474e 100644 --- a/src/Plugins/Freetype/unicode_font.cpp +++ b/src/Plugins/Freetype/unicode_font.cpp @@ -777,6 +777,7 @@ unicode_font_rep::magnify (double zoomx, double zoomy) { void unicode_font_rep::advance_glyph (string s, int& pos, bool ligf) { + cout << "advance_glyph for " << s << ", " << pos << "\n"; if (pos >= N (s)) return; unsigned int uc= read_unicode_char (s, pos); if (ligs > 0 && ligf && (((char) uc) == 'f' || ((char) uc) == 's')) @@ -808,7 +809,7 @@ unicode_font_rep::index_glyph (string s, font_metric& rm, font_glyphs& rg) { if (is_nil (gl)) return font_rep::index_glyph (s, rm, rg); rm= fnm; rg= fng; - return uc; + return uc; } static bool