View Issue Details

IDProjectCategoryView StatusLast Update
0011168mantisbtreportspublic2016-07-09 19:28
Reportersquarebox Assigned Tovboctor  
PrioritynormalSeverityblockReproducibilityalways
Status closedResolutionduplicate 
Product Version1.2.0rc2 
Summary0011168: Graph plugin doesn't gracefully handle Asian fonts that lack a bold style
Description

In customizing the mantis graph plugin to support east-asian fonts i found that the plugin would fail if the FS_BOLD value wasn't specified, which is seemingly the case for jpgraph's implementation of the fonts. Which required me to edit to the jpgraph_ttf.inc.php file to work around this.

Would it be possible to have to the graph plugin use FS_NORMAL when FS_BOLD is non-existent or set to null?

Additional Information

jprgaph_ttf.inc.php

JpGraphs implementation of PMincho font

    FF_PMINCHO  =>  array(
        FS_NORMAL =>PMINCHO_TTF_FONT,
        FS_BOLD =>'',
        FS_ITALIC =>'',
        FS_BOLDITALIC =>'' ),
TagsNo tags attached.
Attached Files
QS_20091113-143715.jpg (84,325 bytes)   
QS_20091113-143715.jpg (84,325 bytes)   

Relationships

duplicate of 0007937 closedatrol Special characters not correctly displayed in graphs 
related to 0011169 closedvboctor Add support for some of the East-asians (Japanese, Korean, Chinese) fonts to mantisgraph 

Activities

dregad

dregad

2012-11-29 09:58

developer   ~0034424

After 3 years of silence I'm not sure if you're still interested in having feedback on your request, but anyway here it goes...

I personally think that a "clean" fallback to FS_NORMAL should ideally be handled by JPGraph, rather than them just throwing an exception and aborting the graph's generation. That said, JPGraph development seems dead for over 2 years, so I see little chance of anything happening in this area.

Of course we can also work around this in MantisBT either by sticking to FS_NORMAL, or by defining a function to apply a font style in graph_api.php, like this (tested with JPGraph 3.5):


/**

  • Allows a 'safe' use of the specified font style, i.e. reduces the risk of an
  • exception being thrown when the graph is drawn in case the style is not
  • defined for the given font. This is done by falling back to FS_NORMAL if the
  • style does not exist.
  • example: $graph->title->SetFont($font, graph_font_style( $font, FS_BOLD ));
  • @param int $pfont JPGraph font family (FF* constants)
  • @param int $pstyle Font style to use (FS* constants), defaults to FS_BOLD
  • @return int Font style to use in SetFont() calls
    */
    function graph_font_style( $p_font, $p_style = FS_BOLD ) {
    $t_ttf = new TTF;

    try {
    $t_ttf->File( $p_font, $p_style );
    }
    catch( exception $e ) {

    Assume failure due to non-existent style, fall back to FS_NORMAL

    # other exceptions will be caught and displayed when the graph is drawn
    return FS_NORMAL;

    }

    return $p_style;
    }

Then, various calls to SetFont() can be replaced as follows:

  • $graph->title->SetFont( $t_graph_font, FS_BOLD );
  • $graph->title->SetFont( $t_graph_font, graph_font_style( $t_graph_font, FS_BOLD ) );

Let me know if that works for you, and if you complete a revision of the MantisGraph plugin with Asian fonts compatibility, upload it here and I'll see if I can add it to core.