From 599be43472927a99764bc0a5fd9d9bf5d07cb150 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Tue, 19 Jul 2005 15:22:55 +0000 Subject: [PATCH] Implemented GetHasGlyphs support somehow (FT support is lacking) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13766 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/servers/app/ServerFont.h | 3 +++ src/kits/interface/Font.cpp | 2 ++ src/servers/app/ServerApp.cpp | 28 ++++++++++++++++++++++++ src/servers/app/ServerFont.cpp | 17 ++++++++++++++ 4 files changed, 50 insertions(+) diff --git a/headers/private/servers/app/ServerFont.h b/headers/private/servers/app/ServerFont.h index 4365d1c77c..ea000a0b37 100644 --- a/headers/private/servers/app/ServerFont.h +++ b/headers/private/servers/app/ServerFont.h @@ -133,6 +133,9 @@ class ServerFont { BShape** GetGlyphShapes(const char charArray[], int32 numChars) const; + void GetHasGlyphs(const char charArray[], + int32 numChars, bool hasArray[]) const; + BPoint* GetEscapements(const char charArray[], int32 numChars, BPoint offsetArray[]) const; diff --git a/src/kits/interface/Font.cpp b/src/kits/interface/Font.cpp index 1c545f673c..22a6b02e30 100644 --- a/src/kits/interface/Font.cpp +++ b/src/kits/interface/Font.cpp @@ -1171,6 +1171,8 @@ BFont::GetHasGlyphs(const char charArray[], int32 numChars, bool hasArray[]) con BPrivate::AppServerLink link; link.StartMessage(AS_GET_HAS_GLYPHS); + link.Attach(fFamilyID); + link.Attach(fStyleID); link.Attach(numChars); link.Attach(charArray, numChars); diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp index 212a9cc661..1703eeb576 100644 --- a/src/servers/app/ServerApp.cpp +++ b/src/servers/app/ServerApp.cpp @@ -1786,6 +1786,34 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) fLink.Flush(); break; } + case AS_GET_HAS_GLYPHS: + { + FTRACE(("ServerApp %s: AS_GET_HAS_GLYPHS\n", Signature())); + // Attached Data: + // 1) uint16 - family ID + // 2) uint16 - style ID + // 3) int32 - numChars + // 4) char - chars (numChars times) + + uint16 famid, styid; + link.Read(&famid); + link.Read(&styid); + int32 numChars; + link.Read(&numChars); + char charArray[numChars]; + link.Read(&charArray, numChars); + + ServerFont font; + if (font.SetFamilyAndStyle(famid, styid) == B_OK) { + bool hasArray[numChars]; + font.GetHasGlyphs(charArray, numChars, hasArray); + fLink.StartMessage(SERVER_TRUE); + fLink.Attach(hasArray, sizeof(hasArray)); + } else + fLink.StartMessage(SERVER_FALSE); + fLink.Flush(); + break; + } case AS_GET_ESCAPEMENTS: { FTRACE(("ServerApp %s: AS_GET_ESCAPEMENTS\n", Signature())); diff --git a/src/servers/app/ServerFont.cpp b/src/servers/app/ServerFont.cpp index d1987aef80..f7f97252a4 100644 --- a/src/servers/app/ServerFont.cpp +++ b/src/servers/app/ServerFont.cpp @@ -322,6 +322,7 @@ ServerFont::GetGlyphShapes(const char charArray[], int32 numChars) const for (int i = 0; i < numChars; i++) { shapes[i] = new BShape(); shapes[i]->Clear(); + // TODO : this is wrong (the nth char isn't charArray[i]) FT_Load_Char(face, charArray[i], FT_LOAD_NO_BITMAP); FT_Outline outline = face->glyph->outline; FT_Outline_Decompose(&outline, &funcs, shapes[i]); @@ -331,6 +332,21 @@ ServerFont::GetGlyphShapes(const char charArray[], int32 numChars) const return shapes; } + +void +ServerFont::GetHasGlyphs(const char charArray[], int32 numChars, bool hasArray[]) const +{ + if (!fStyle || !charArray || numChars <= 0 || !hasArray) + return; + + // TODO : implement for real + + for (int i = 0; i < numChars; i++) { + hasArray[i] = true; + } +} + + // GetEscapements BPoint* ServerFont::GetEscapements(const char charArray[], int32 numChars, @@ -374,6 +390,7 @@ ServerFont::GetEscapements(const char charArray[], int32 numChars, // TODO: handle UTF8... see below!! BPoint *escapements = (BPoint *)malloc(sizeof(BPoint) * numChars); for (int i = 0; i < numChars; i++) { + // TODO : this is wrong (the nth char isn't charArray[i]) FT_Load_Char(face, charArray[i], FT_LOAD_NO_BITMAP); // escapements[i].x = float(face->glyph->metrics.width / 64) / fSize; // escapements[i].y = 0;