Skip to content

Commit bf8f333

Browse files
committed
solved a few unicode font problems, including the angstrom bug gnudatalanguage#862.
Now TTF fonts in wx plots are ok.
1 parent ea7fa01 commit bf8f333

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/gdlgstream.cpp

+12-10
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ void GDLGStream::GetGeometry( long& xSize, long& ySize)
351351
{
352352
bool debug = false;
353353
static char errmsg[] = "No such font: ";
354+
static std::string begin_unicode="#[";
355+
static std::string end_unicode="]";
354356
static const size_t errmsglen = strlen(errmsg);
355357
static double fact[]={1.,0.9,0.666,0.5,0.45,0.33,0.2};
356358
double base=1.0;
@@ -670,8 +672,8 @@ void GDLGStream::GetGeometry( long& xSize, long& ySize)
670672
case 'C' : // tick sign
671673
out += " "; break;
672674
break;
673-
default :
674-
out.append(in, i, 1);
675+
default :
676+
if ((unsigned char)in[i] > 127) { out+=begin_unicode; out+=to_string((unsigned char)in[i]); out+=end_unicode; } else out.append(in, i, 1); //use unicode
675677
break;
676678
}
677679
break;
@@ -775,7 +777,7 @@ void GDLGStream::GetGeometry( long& xSize, long& ySize)
775777
case 'z' : out += "#(2305)"; break; // ?
776778
case 'm' : out += "#(899)"; break; // smallest circle - dot
777779
default :
778-
out.append(in, i, 1);
780+
if ((unsigned char)in[i] > 127) { out+=begin_unicode; out+=to_string((unsigned char)in[i]); out+=end_unicode; } else out.append(in, i, 1); //use unicode
779781
break;
780782
}
781783
break;
@@ -815,7 +817,7 @@ void GDLGStream::GetGeometry( long& xSize, long& ySize)
815817
case '"' : out += "#(2831)"; break; case '^' : case '~' : out += "#(2931)"; break; // [yu]
816818
case 127u : case '_' : out += "#(2832)"; break; case ';' : out += "#(2932)"; break; // [ya]
817819
default :
818-
out.append(in, i, 1);
820+
if ((unsigned char)in[i] > 127) { out+=begin_unicode; out+=to_string((unsigned char)in[i]); out+=end_unicode; } else out.append(in, i, 1); //use unicode
819821
break;
820822
}
821823
break;
@@ -851,9 +853,9 @@ void GDLGStream::GetGeometry( long& xSize, long& ySize)
851853
case 'I' : case 'i' :
852854
case 'O' : case 'o' :
853855
case 'P' : case 'p' :
854-
out += "#g";
856+
out += "#g"; out.append(in, i, 1); break;
855857
default :
856-
out.append(in, i, 1);
858+
if ((unsigned char)in[i] > 127) { out+=begin_unicode; out+=to_string((unsigned char)in[i]); out+=end_unicode; } else out.append(in, i, 1); //use unicode
857859
break;
858860
}
859861
break;
@@ -877,13 +879,13 @@ void GDLGStream::GetGeometry( long& xSize, long& ySize)
877879
case 190u : out += "#(271)"; break; // 3/4
878880
case 215u : out += "#(846)"; break; // cross sign
879881
case 223u : out += "#fs#gb"; out += internalFontCodes[curr_fnt]; break; // beta script
880-
default :
881-
out.append(in, i, 1);
882+
default :
883+
if ((unsigned char)in[i] > 127) { out+=begin_unicode; out+=to_string((unsigned char)in[i]); out+=end_unicode; } else out.append(in, i, 1); //use unicode
882884
break;
883885
}
884886
break;
885887
default : // simply pass the char
886-
out.append(in, i, 1);
888+
if ((unsigned char)in[i] > 127) { out+=begin_unicode; out+=to_string((unsigned char)in[i]); out+=end_unicode; } else out.append(in, i, 1); //use unicode
887889
break;
888890
}
889891
curr_fnt = next_fnt;
@@ -898,7 +900,7 @@ void GDLGStream::GetGeometry( long& xSize, long& ySize)
898900
retrn:
899901
activeFontCodeNum = curr_fnt;
900902
if (stringLength) *stringLength=0;
901-
if (debug) cout << "GDLGStream::TranslateFormatCodes(\"" << in << "\") = \"" << out << "\"" << endl;
903+
cout << "ERROR: GDLGStream::TranslateFormatCodes(\"" << in << "\") = \"" << out << "\"" << endl;
902904
return "";
903905
}
904906

0 commit comments

Comments
 (0)