Skip to content

Commit e940c25

Browse files
committed
experimental: trying if custom text underlining algo can be implemented
1 parent 824965b commit e940c25

File tree

6 files changed

+365
-14
lines changed

6 files changed

+365
-14
lines changed

class/Drawable.cls

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ object Prima::Drawable ( Prima::Component)
7676
static SV * render_polyline( SV * obj, SV * points, HV * profile);
7777
import Handle render_pattern( SV * obj, SV * pattern, HV * profile);
7878
static SV * render_spline( SV * obj, SV * points, HV * profile);
79+
method SV * render_underline(SV * glyphs);
7980
method Bool graphic_context_push();
8081
method Bool graphic_context_pop();
8182

@@ -99,6 +100,7 @@ object Prima::Drawable ( Prima::Component)
99100
PFontABC font_abc_ascii;
100101
PList font_abc_unicode;
101102
PList font_abc_glyphs;
103+
PList font_def_glyphs;
102104
unsigned long * font_abc_glyphs_ranges;
103105
int font_abc_glyphs_n_ranges;
104106

class/Drawable/fonts.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ Drawable_clear_font_abc_caches( Handle self)
1717
plist_destroy( u);
1818
var-> font_abc_glyphs = NULL;
1919
}
20+
if (( u = var-> font_def_glyphs)) {
21+
int i;
22+
for ( i = 0; i < u-> count; i += 2)
23+
free(( void*) u-> items[ i + 1]);
24+
plist_destroy( u);
25+
var-> font_def_glyphs = NULL;
26+
}
2027
if (( u = var-> font_abc_unicode)) {
2128
int i;
2229
for ( i = 0; i < u-> count; i += 2)

class/Drawable/line_ends.c

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,68 @@ Drawable_lineEndIndex( Handle self, Bool set, int index, SV *lineEnd)
387387
return NULL_SV;
388388
}
389389

390+
int
391+
Drawable_resolve_line_end_index( DrawablePaintState *gs, int index)
392+
{
393+
int le = gs->line_end[index].type;
394+
while ( le == leDefault ) {
395+
switch ( index ) {
396+
case leiLineTail:
397+
le = leRound;
398+
break;
399+
case leiLineHead:
400+
case leiArrowTail:
401+
index = leiLineTail;
402+
le = gs->line_end[index].type;
403+
break;
404+
case leiArrowHead:
405+
index = leiLineHead;
406+
le = gs->line_end[index].type;
407+
break;
408+
default:;
409+
}
410+
}
411+
return index;
412+
}
413+
414+
NRect
415+
Drawable_line_end_box( DrawablePaintState *gs, int index)
416+
{
417+
NRect r = {0,0,0,0};
418+
LineEnd *le = gs->line_end + index;
419+
420+
switch ( le->type ) {
421+
case leRound:
422+
case leSquare:
423+
r.left = r.bottom = r.right = r.top = 0.5;
424+
break;
425+
case leCustom: {
426+
int k;
427+
PPath p = le->path;
428+
for ( k = 0; k < p->n_commands; k++) {
429+
int l;
430+
PPathCommand pc = p->commands[k];
431+
double *pts = pc->args;
432+
for ( l = 0; l < pc->n_args; l++) {
433+
if ( *pts < r.left )
434+
r.left = *pts;
435+
if ( *pts > r.right )
436+
r.right = *pts;
437+
pts++;
438+
if ( *pts < r.bottom )
439+
r.bottom = *pts;
440+
if ( *pts > r.top )
441+
r.top = *pts;
442+
pts++;
443+
}
444+
}
445+
break;
446+
}
447+
default:;
448+
}
449+
450+
return r;
451+
}
390452

391453
#ifdef __cplusplus
392454
}

class/Drawable/text.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ Drawable_get_text_box( Handle self, SV * text, int from, int len )
393393
GlyphsOutRec t;
394394
dmCHECK(NULL_SV);
395395
if (!Drawable_read_glyphs(&t, text, 0, "Drawable::get_text_box"))
396-
return false;
396+
return newRV_noinc(( SV *) newAV());
397397
if (( len = Drawable_check_length(from,len,t.len)) == 0)
398398
return newRV_noinc(( SV *) newAV());
399399
Drawable_hop_glyphs(&t, from, len);

0 commit comments

Comments
 (0)