mirror of https://github.com/buggins/dlangui.git
Merge pull request #606 from seoyoungjin/seoyoungjin
TTC(truetype collection) file extention and OEM charset face name on Windows
This commit is contained in:
commit
79434226cc
|
@ -239,6 +239,8 @@ class Font : RefCountedObject {
|
||||||
bool fixed = isFixed;
|
bool fixed = isFixed;
|
||||||
bool useKerning = allowKerning && !fixed;
|
bool useKerning = allowKerning && !fixed;
|
||||||
int fixedCharWidth = charWidth('M');
|
int fixedCharWidth = charWidth('M');
|
||||||
|
if (fixedCharWidth == 0)
|
||||||
|
fixedCharWidth = spaceWidth;
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int charsMeasured = 0;
|
int charsMeasured = 0;
|
||||||
int * pwidths = widths.ptr;
|
int * pwidths = widths.ptr;
|
||||||
|
|
|
@ -771,7 +771,9 @@ bool registerFontConfigFonts(FreeTypeFontManager fontMan) {
|
||||||
}
|
}
|
||||||
string fn = fromStringz(s).dup;
|
string fn = fromStringz(s).dup;
|
||||||
string fn16 = toLower(fn);
|
string fn16 = toLower(fn);
|
||||||
if (!fn16.endsWith(".ttf") && !fn16.endsWith(".odf") && !fn16.endsWith(".otf") && !fn16.endsWith(".pfb") && !fn16.endsWith(".pfa") ) {
|
if (!fn16.endsWith(".ttf") && !fn16.endsWith(".odf") && !fn16.endsWith(".otf") &&
|
||||||
|
!fn16.endsWith(".ttc") && !fn16.endsWith(".pfb") && !fn16.endsWith(".pfa") )
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int weight = FC_WEIGHT_MEDIUM;
|
int weight = FC_WEIGHT_MEDIUM;
|
||||||
|
@ -912,9 +914,6 @@ bool registerFontConfigFonts(FreeTypeFontManager fontMan) {
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
*/
|
||||||
facesFound++;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FcFontSetDestroy(fontset);
|
FcFontSetDestroy(fontset);
|
||||||
|
|
|
@ -30,6 +30,7 @@ import dlangui.graphics.fonts;
|
||||||
import dlangui.platforms.windows.win32drawbuf;
|
import dlangui.platforms.windows.win32drawbuf;
|
||||||
import std.string;
|
import std.string;
|
||||||
import std.utf;
|
import std.utf;
|
||||||
|
import std.windows.charset;
|
||||||
|
|
||||||
/// define debug=FontResources for logging of font file resources creation/freeing
|
/// define debug=FontResources for logging of font file resources creation/freeing
|
||||||
//debug = FontResources;
|
//debug = FontResources;
|
||||||
|
@ -446,9 +447,13 @@ class Win32Font : Font {
|
||||||
if (!isNull())
|
if (!isNull())
|
||||||
clear();
|
clear();
|
||||||
LOGFONTA lf;
|
LOGFONTA lf;
|
||||||
lf.lfCharSet = ANSI_CHARSET; //DEFAULT_CHARSET;
|
// OEM charset face name
|
||||||
lf.lfFaceName[0..def.face.length] = def.face;
|
lf.lfCharSet = DEFAULT_CHARSET; //ANSI_CHARSET;
|
||||||
lf.lfFaceName[def.face.length] = 0;
|
// lf.lfFaceName[0..def.face.length] = def.face;
|
||||||
|
// lf.lfFaceName[def.face.length] = 0;
|
||||||
|
string oemFace = fromStringz(toMBSz(def.face)).dup;
|
||||||
|
lf.lfFaceName[0..oemFace.length] = oemFace;
|
||||||
|
lf.lfFaceName[oemFace.length] = 0;
|
||||||
lf.lfHeight = -size; //pixelsToPoints(size);
|
lf.lfHeight = -size; //pixelsToPoints(size);
|
||||||
lf.lfItalic = italic;
|
lf.lfItalic = italic;
|
||||||
lf.lfWeight = weight;
|
lf.lfWeight = weight;
|
||||||
|
@ -545,7 +550,7 @@ class Win32FontManager : FontManager {
|
||||||
debug Log.i("Win32FontManager.initialize()");
|
debug Log.i("Win32FontManager.initialize()");
|
||||||
Win32ColorDrawBuf drawbuf = new Win32ColorDrawBuf(1,1);
|
Win32ColorDrawBuf drawbuf = new Win32ColorDrawBuf(1,1);
|
||||||
LOGFONTA lf;
|
LOGFONTA lf;
|
||||||
lf.lfCharSet = ANSI_CHARSET; //DEFAULT_CHARSET;
|
lf.lfCharSet = DEFAULT_CHARSET; //ANSI_CHARSET;
|
||||||
lf.lfFaceName[0] = 0;
|
lf.lfFaceName[0] = 0;
|
||||||
HDC dc = drawbuf.dc;
|
HDC dc = drawbuf.dc;
|
||||||
int res =
|
int res =
|
||||||
|
@ -705,7 +710,9 @@ extern(Windows) {
|
||||||
{
|
{
|
||||||
void * p = cast(void*)lParam;
|
void * p = cast(void*)lParam;
|
||||||
Win32FontManager fontman = cast(Win32FontManager)p;
|
Win32FontManager fontman = cast(Win32FontManager)p;
|
||||||
string face = fromStringz(lf.lfFaceName.ptr).dup;
|
// OEM charset face name
|
||||||
|
// string face = fromStringz(lf.lfFaceName.ptr).dup;
|
||||||
|
string face = fromMBSz(cast(immutable)lf.lfFaceName.ptr).dup;
|
||||||
FontFamily family = pitchAndFamilyToFontFamily(lf.lfPitchAndFamily);
|
FontFamily family = pitchAndFamilyToFontFamily(lf.lfPitchAndFamily);
|
||||||
if (face.length < 2 || face[0] == '@')
|
if (face.length < 2 || face[0] == '@')
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in New Issue