Font_FontMgr - setup system fonts "Droid Sans Mono", "Droid Serif" and "Roboto" as aliases to "Courier", "Times" and "Arial" on Android.
Locate Android system fonts in directory "/system/fonts".
OpenGl_Text::FindFont() - print error message on missed fonts.
OpenGl_Text::render() - allow straightforward font rendering on OpenGL ES.
Do not use "Webdings" in tests.
Drop duplicating test case bugs/vis/bug21091_2.
static const Font_FontMgr_FontAliasMapNode Font_FontMgr_MapOfFontsAliases[] =
{
-#ifdef WNT
+#ifdef _WIN32
{ "Courier" , "Courier New" , Font_FA_Regular },
{ "Times-Roman" , "Times New Roman", Font_FA_Regular },
{ "Rock" , "Arial" , Font_FA_Regular },
{ "Iris" , "Lucida Console" , Font_FA_Regular }
+#elif defined(__ANDROID__)
+
+ { "Courier" , "Droid Sans Mono", Font_FA_Regular },
+ { "Times-Roman" , "Droid Serif" , Font_FA_Regular },
+ { "Times-Bold" , "Droid Serif" , Font_FA_Bold },
+ { "Times-Italic" , "Droid Serif" , Font_FA_Italic },
+ { "Times-BoldItalic" , "Droid Serif" , Font_FA_BoldItalic },
+ { "Arial" , "Roboto" , Font_FA_Regular },
+
#else //X11
{ "Courier" , "Courier" , Font_FA_Regular },
{ "Times-Bold" , "Times" , Font_FA_Bold },
{ "Times-Italic" , "Times" , Font_FA_Italic },
{ "Times-BoldItalic" , "Times" , Font_FA_BoldItalic },
- { "Arial" , "Helvetica" , Font_FA_Regular },
+ { "Arial" , "Helvetica" , Font_FA_Regular },
{ "ZapfChancery-MediumItalic", "-adobe-itc zapf chancery-medium-i-normal--*-*-*-*-*-*-iso8859-1" , Font_FA_Regular },
{ "Symbol" , "-adobe-symbol-medium-r-normal--*-*-*-*-*-*-adobe-fontspecific" , Font_FA_Regular },
{ "ZapfDingbats" , "-adobe-itc zapf dingbats-medium-r-normal--*-*-*-*-*-*-adobe-fontspecific" , Font_FA_Regular },
#define NUM_FONT_ENTRIES (int)(sizeof(Font_FontMgr_MapOfFontsAliases)/sizeof(Font_FontMgr_FontAliasMapNode))
-#if (defined(_WIN32) || defined(__WIN32__))
+#if defined(_WIN32)
#include <windows.h>
#include <stdlib.h>
#else
#include <OSD_DirectoryIterator.hxx>
+ #include <OSD_FileIterator.hxx>
#include <OSD_Path.hxx>
#include <OSD_File.hxx>
#include <OSD_OpenMode.hxx>
};
#else
// default fonts paths in most Unix systems (Linux and others)
- static Standard_CString myDefaultFontsDirs[] = {"/usr/share/fonts",
+ static Standard_CString myDefaultFontsDirs[] = {"/system/fonts", // Android
+ "/usr/share/fonts",
"/usr/local/share/fonts",
NULL
};
for (NCollection_Map<TCollection_AsciiString>::Iterator anIter (aMapOfFontsDirs);
anIter.More(); anIter.Next())
{
+ #ifdef __ANDROID__
+ OSD_Path aFolderPath (anIter.Value());
+ for (OSD_FileIterator aFileIter (aFolderPath, "*"); aFileIter.More(); aFileIter.Next())
+ {
+ OSD_Path aFontFilePath;
+ aFileIter.Values().Path (aFontFilePath);
+
+ TCollection_AsciiString aFontFileName;
+ aFontFilePath.SystemName (aFontFileName);
+ aFontFileName = anIter.Value() + "/" + aFontFileName;
+
+ Handle(Font_SystemFont) aNewFont = checkFont (aFtLibrary, aFontFileName.ToCString());
+ if (!aNewFont.IsNull())
+ {
+ myListOfFonts.Append (aNewFont);
+ }
+ }
+ #else
OSD_File aReadFile (anIter.Value() + "/fonts.dir");
if (!aReadFile.Exists())
{
{
myListOfFonts.Append (aNewFontFromXLFD);
}
-
}
}
aReadFile.Close();
+ #endif
}
#endif
}
{
if ( (theFontSize < 2 && theFontSize != -1) || theFontName.IsNull())
{
- return NULL;
+ return NULL;
}
for (Font_NListOfSystemFont::Iterator aFontsIterator (myListOfFonts);
void OpenGl_PrimitiveArray::drawEdges (const TEL_COLOUR* theEdgeColour,
const Handle(OpenGl_Workspace)& theWorkspace) const
{
+ const Handle(OpenGl_Context)& aGlContext = theWorkspace->GetGlContext();
if (myVboAttribs.IsNull())
{
return;
}
#if !defined(GL_ES_VERSION_2_0)
- glDisable (GL_LIGHTING);
+ if (aGlContext->core11 != NULL)
+ {
+ glDisable (GL_LIGHTING);
+ }
#endif
- const Handle(OpenGl_Context)& aGlContext = theWorkspace->GetGlContext();
const OpenGl_AspectLine* anAspectLineOld = NULL;
anAspectLineOld = theWorkspace->SetAspectLine (theWorkspace->AspectFace (Standard_True)->AspectEdge());
{
drawEdges (anEdgeColor, theWorkspace);
- #if !defined(GL_ES_VERSION_2_0)
// restore OpenGL polygon mode if needed
+ #if !defined(GL_ES_VERSION_2_0)
if (anAspectFace->InteriorStyle() >= Aspect_IS_HATCH)
{
glPolygonMode (GL_FRONT_AND_BACK,
const Handle(TCollection_HAsciiString) aFontName = new TCollection_HAsciiString (theAspect.FontName());
const Font_FontAspect anAspect = (theAspect.FontAspect() != Font_FA_Undefined) ? theAspect.FontAspect() : Font_FA_Regular;
Handle(Font_SystemFont) aRequestedFont = aFontMgr->FindFont (aFontName, anAspect, theHeight);
- if (aRequestedFont.IsNull())
+ Handle(Font_FTFont) aFontFt;
+ if (!aRequestedFont.IsNull())
{
- return aFont;
- }
-
- Handle(Font_FTFont) aFontFt = new Font_FTFont (NULL);
- if (!aFontFt->Init (aRequestedFont->FontPath()->ToCString(), theHeight))
- {
- return aFont;
+ aFontFt = new Font_FTFont (NULL);
+ if (aFontFt->Init (aRequestedFont->FontPath()->ToCString(), theHeight))
+ {
+ aFont = new OpenGl_Font (aFontFt, theKey);
+ if (!aFont->Init (theCtx))
+ {
+ TCollection_ExtendedString aMsg;
+ aMsg += "Font '";
+ aMsg += theAspect.FontName();
+ aMsg += "' - initialization of GL resources has failed!";
+ theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION_ARB, GL_DEBUG_TYPE_ERROR_ARB, 0, GL_DEBUG_SEVERITY_HIGH_ARB, aMsg);
+ aFontFt.Nullify();
+ aFont = new OpenGl_Font (aFontFt, theKey);
+ }
+ }
+ else
+ {
+ TCollection_ExtendedString aMsg;
+ aMsg += "Font '";
+ aMsg += theAspect.FontName();
+ aMsg += "' is broken or has incompatible format! File path: ";
+ aMsg += aRequestedFont->FontPath()->ToCString();
+ theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION_ARB, GL_DEBUG_TYPE_ERROR_ARB, 0, GL_DEBUG_SEVERITY_HIGH_ARB, aMsg);
+ aFontFt.Nullify();
+ aFont = new OpenGl_Font (aFontFt, theKey);
+ }
}
-
- aFont = new OpenGl_Font (aFontFt, theKey);
-
- if (!aFont->Init (theCtx))
+ else
{
- // out of resources?
+ TCollection_ExtendedString aMsg;
+ aMsg += "Font '";
+ aMsg += theAspect.FontName();
+ aMsg += "' is not found in the system!";
+ theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION_ARB, GL_DEBUG_TYPE_ERROR_ARB, 0, GL_DEBUG_SEVERITY_HIGH_ARB, aMsg);
+ aFont = new OpenGl_Font (aFontFt, theKey);
}
theCtx->ShareResource (theKey, aFont);
if (myFont.IsNull())
{
myFont = FindFont (theCtx, theTextAspect, myParams.Height, aFontKey);
- if (myFont.IsNull())
- {
- return;
- }
+ }
+ if (!myFont->WasInitialized())
+ {
+ return;
}
if (myTextures.IsEmpty())
myExportHeight = (float )myFont->FTFont()->PointSize() / myExportHeight;
#if !defined(GL_ES_VERSION_2_0)
-
- glDisable (GL_LIGHTING);
+ if (theCtx->core11 != NULL)
+ {
+ glDisable (GL_LIGHTING);
+ }
+#endif
// setup depth test
if (!myIs2d
glDisable (GL_DEPTH_TEST);
}
- // setup alpha test
- GLint aTexEnvParam = GL_REPLACE;
- glGetTexEnviv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &aTexEnvParam);
- if (aTexEnvParam != GL_REPLACE)
+ if (theCtx->core15fwd != NULL)
{
- glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ theCtx->core15fwd->glActiveTexture (GL_TEXTURE0);
}
+#if !defined(GL_ES_VERSION_2_0)
+ // setup alpha test
glAlphaFunc (GL_GEQUAL, 0.285f);
glEnable (GL_ALPHA_TEST);
- // setup blending
- glEnable (GL_BLEND);
- glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // GL_ONE
-
// activate texture unit
- glDisable (GL_TEXTURE_1D);
- glEnable (GL_TEXTURE_2D);
- if (theCtx->core15fwd != NULL)
+ GLint aTexEnvParam = GL_REPLACE;
+ if (theCtx->core11 != NULL)
{
- theCtx->core15fwd->glActiveTexture (GL_TEXTURE0);
+ glDisable (GL_TEXTURE_1D);
+ glEnable (GL_TEXTURE_2D);
+ glGetTexEnviv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &aTexEnvParam);
+ if (aTexEnvParam != GL_REPLACE)
+ {
+ glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ }
}
+#endif
+
+ // setup blending
+ glEnable (GL_BLEND);
+ glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// extra drawings
switch (theTextAspect.DisplayType())
{
case Aspect_TODT_BLEND:
{
+ #if !defined(GL_ES_VERSION_2_0)
glEnable (GL_COLOR_LOGIC_OP);
glLogicOp (GL_XOR);
+ #endif
break;
}
case Aspect_TODT_SUBTITLE:
{
- theCtx->core11->glColor3fv (theColorSubs.rgb);
- setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (0.0f, 0.0f, 0.00001f));
-
- glBindTexture (GL_TEXTURE_2D, 0);
- glBegin (GL_QUADS);
- glVertex2f (myBndBox.Left, myBndBox.Top);
- glVertex2f (myBndBox.Right, myBndBox.Top);
- glVertex2f (myBndBox.Right, myBndBox.Bottom);
- glVertex2f (myBndBox.Left, myBndBox.Bottom);
- glEnd();
+ #if !defined(GL_ES_VERSION_2_0)
+ if (theCtx->core11 != NULL)
+ {
+ theCtx->core11->glColor3fv (theColorSubs.rgb);
+ setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (0.0f, 0.0f, 0.00001f));
+
+ glBindTexture (GL_TEXTURE_2D, 0);
+ glBegin (GL_QUADS);
+ glVertex2f (myBndBox.Left, myBndBox.Top);
+ glVertex2f (myBndBox.Right, myBndBox.Top);
+ glVertex2f (myBndBox.Right, myBndBox.Bottom);
+ glVertex2f (myBndBox.Left, myBndBox.Bottom);
+ glEnd();
+ }
+ #endif
break;
}
case Aspect_TODT_DEKALE:
setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (0.0f, 0.0f, 0.0f));
drawText (thePrintCtx, theCtx, theTextAspect);
- glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, aTexEnvParam);
+#if !defined(GL_ES_VERSION_2_0)
+ if (theCtx->core11 != NULL)
+ {
+ glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, aTexEnvParam);
+ }
+#endif
if (theTextAspect.DisplayType() == Aspect_TODT_DIMENSION)
{
setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (0.0f, 0.0f, 0.00001f));
glDisable (GL_BLEND);
- glDisable (GL_TEXTURE_2D);
- glDisable (GL_ALPHA_TEST);
if (!myIs2d)
{
glDisable (GL_DEPTH_TEST);
}
+ #if !defined(GL_ES_VERSION_2_0)
+ if (theCtx->core11 != NULL)
+ {
+ glDisable (GL_TEXTURE_2D);
+ glDisable (GL_ALPHA_TEST);
+ }
+ #endif
glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
glClear (GL_STENCIL_BUFFER_BIT);
glStencilFunc (GL_ALWAYS, 1, 0xFF);
glStencilOp (GL_KEEP, GL_KEEP, GL_REPLACE);
- glBegin (GL_QUADS);
- glVertex2f (myBndBox.Left, myBndBox.Top);
- glVertex2f (myBndBox.Right, myBndBox.Top);
- glVertex2f (myBndBox.Right, myBndBox.Bottom);
- glVertex2f (myBndBox.Left, myBndBox.Bottom);
- glEnd();
+ #if !defined(GL_ES_VERSION_2_0)
+ if (theCtx->core11 != NULL)
+ {
+ glBegin (GL_QUADS);
+ glVertex2f (myBndBox.Left, myBndBox.Top);
+ glVertex2f (myBndBox.Right, myBndBox.Top);
+ glVertex2f (myBndBox.Right, myBndBox.Bottom);
+ glVertex2f (myBndBox.Left, myBndBox.Bottom);
+ glEnd();
+ }
+ #endif
glStencilFunc (GL_ALWAYS, 0, 0xFF);
// reset OpenGL state
glDisable (GL_BLEND);
- glDisable (GL_ALPHA_TEST);
glDisable (GL_STENCIL_TEST);
+#if !defined(GL_ES_VERSION_2_0)
+ glDisable (GL_ALPHA_TEST);
glDisable (GL_COLOR_LOGIC_OP);
+#endif
// model view matrix was modified
theCtx->WorldViewState.Pop();
theCtx->ApplyModelViewMatrix();
-#endif
}
vdrawtext OpenCascade -200 -200 150 000 255 255 0 0 010 0 15 1 Arbat
vdrawtext OpenCascade -200 -200 200 255 255 000 0 0 010 0 15 3 Elephant
vdrawtext OpenCascade -200 -200 250 000 255 005 0 0 010 0 15 4 RockWell
-vdrawtext OpenCascade -200 -200 300 255 000 005 0 0 010 0 15 1 Webdings
-vdrawtext OpenCascade -200 -200 350 255 000 205 0 0 010 0 15 1 Arial
+vdrawtext OpenCascade -200 -200 300 255 000 005 0 0 010 0 15 1 Arial
+++ /dev/null
-puts "============"
-puts "OCC21091"
-puts "OCC21450"
-puts "============"
-puts ""
-#vdrawtext: vdrawtext name X Y Z R G B hor_align ver_align angle zoomable height Aspect FONT
-#------------------------------------------------------
-# X\Y\Z - Position Of Text
-#------------------------------------------------------
-# R\G\B - Color Of Text
-#------------------------------------------------------
-# hor_align 0 to 3
-# HorizontalTextAlignment is HTA_LEFT 0
-# HTA_CENTER 1
-# HTA_RIGHT 2
-#
-# ver_align 0 to 4
-# VerticalTextAlignment is VTA_BOTTOM 0
-# VTA_CENTER 1
-# VTA_TOP 2
-#------------------------------------------------------
-# angle - angle turn of text. this variable in degrees
-#------------------------------------------------------
-# zoomable - if this variable "0" text not zoomable
-# if this variable "1" text zoomable as object in DrawCommands
-#------------------------------------------------------
-# height - Font Height
-#------------------------------------------------------
-# Aspect - Aspect Font 0 to 4
-# If in list of textfont, not find font with necessary aspect, will be used default font "Courier" with OSD_FA_Regular aspect
-# FontAspect is FA_Undefined, FA_Regular, FA_Bold, FA_Italic, FA_BoldItalic
-# - 0 - - 1 - - 2 - - 3 - - 4 -
-#------------------------------------------------------
-# FONT - font name of font
-# If in list of textfont, not find font with necessary Name, will be used default font "Courier"
-#
-
-vinit
-set only_screen 1
-
-vtrihedron trihedr
-
-vpoint p1 100 100 -400
-vpoint p2 000 000 -400
-vpoint p3 -100 -100 -400
-vdrawtext OpenCascade 100 100 -400 000 255 255 0 0 000 1 50 1 Times-Roman
-vdrawtext OpenCascade 000 000 -400 000 255 255 1 0 000 1 50 1 Times-Roman
-vdrawtext OpenCascade -100 -100 -400 000 255 255 2 0 000 1 50 1 Times-Roman
-
-vpoint p4 100 100 -500
-vpoint p5 000 000 -500
-vpoint p6 -100 -100 -500
-vdrawtext OpenCascade 100 100 -500 255 000 000 0 2 000 1 50 1 Times-Roman
-vdrawtext OpenCascade 000 000 -500 255 000 000 1 2 000 1 50 1 Times-Roman
-vdrawtext OpenCascade -100 -100 -500 255 000 000 2 2 000 1 50 1 Times-Roman
-
-vpoint p7 100 100 -450
-vpoint p8 000 000 -450
-vpoint p9 -100 -100 -450
-vdrawtext OpenCascade 100 100 -450 005 255 000 0 1 000 1 50 1 Times-Roman
-vdrawtext OpenCascade 000 000 -450 005 255 000 1 1 000 1 50 1 Times-Roman
-vdrawtext OpenCascade -100 -100 -450 005 255 000 2 1 000 1 50 1 Times-Roman
-
-
-vdrawtext _.Left._ 200 200 200 255 255 255 0 0 000 1 50 1 Times-Roman
-vdrawtext _.Left._ 200 200 200 255 255 000 0 0 090 1 50 1 Times-Roman
-
-vdrawtext _.Right._ 200 200 200 255 000 255 2 2 000 1 50 1 Times-Roman
-vdrawtext _.Right._ 200 200 200 255 155 150 2 2 090 1 50 1 Times-Roman
-
-vdrawtext _.0123456789._ 200 200 200 000 000 255 1 1 045 1 50 1 Times-Roman
-vdrawtext _.0123456789._ 200 200 200 255 000 000 1 1 -45 1 50 1 Times-Roman
-
-vdrawtext _.~!@#$%^&*:?|+-._ -200 000 400 255 000 000 0 0 0 1 50 1 Times-Roman
-
-box atextbox -100 -100 -100 -200 -200 -200
-vdisplay atextbox
-
-vdrawtext OpenCascade -300 -300 -300 000 255 000 0 0 000 0 15 1 Courier
-vdrawtext OpenCascade -300 -300 -100 000 255 000 0 0 000 0 15 1 Courier
-vdrawtext OpenCascade -100 -100 -300 000 255 000 0 0 000 0 15 1 Courier
-vdrawtext OpenCascade -100 -100 -100 000 255 000 0 0 000 0 15 1 Courier
-
-vdrawtext OpenCascade -300 -100 -300 000 255 000 0 0 000 0 15 1 Courier
-vdrawtext OpenCascade -100 -300 -300 000 255 000 0 0 000 0 15 1 Courier
-vdrawtext OpenCascade -300 -100 -100 000 255 000 0 0 000 0 15 1 Courier
-vdrawtext OpenCascade -100 -300 -100 000 255 000 0 0 000 0 15 1 Courier
-
-vdrawtext OpenCascade -200 -200 100 255 000 255 0 0 010 0 15 1 Times-Roman
-vdrawtext OpenCascade -200 -200 150 000 255 255 0 0 010 0 15 1 Arbat
-vdrawtext OpenCascade -200 -200 200 255 255 000 0 0 010 0 15 3 Elephant
-vdrawtext OpenCascade -200 -200 250 000 255 005 0 0 010 0 15 4 RockWell
-vdrawtext OpenCascade -200 -200 300 255 000 005 0 0 010 0 15 1 Webdings
-vdrawtext OpenCascade -200 -200 350 255 000 205 0 0 010 0 15 1 Arial