lookup_blitset: degrade from braille smoothly #1334

pull/1338/head
nick black 3 years ago
parent 4d74d23fc6
commit c64de96cbf
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -16,6 +16,22 @@ lookup_blitset(const tinfo* tcache, ncblitter_e setid, bool may_degrade) {
return NULL;
}
}
// without braille support, NCBLIT_BRAILLE decays to NCBLIT_3x2
if(!tcache->braille && setid == NCBLIT_BRAILLE){
if(may_degrade){
setid = NCBLIT_3x2;
}else{
return NULL;
}
}
// without sextant support, NCBLIT_3x2 decays to NCBLIT_2x2
if(!tcache->sextants && setid == NCBLIT_3x2){
if(may_degrade){
setid = NCBLIT_2x2;
}else{
return NULL;
}
}
const struct blitset* bset = notcurses_blitters;
while(bset->egcs){
if(bset->geom == setid){
@ -75,4 +91,12 @@ rgba_blitter(const struct notcurses* nc, const struct ncvisual_options* opts) {
return rgba_blitter_low(&nc->tcache, scale, maydegrade, opts ? opts->blitter : NCBLIT_DEFAULT);
}
static inline ncblitter_e
ncplot_defblitter(const notcurses* nc){
if(notcurses_canutf8(nc)){
return NCBLIT_8x1;
}
return NCBLIT_1x1;
}
#endif

@ -45,11 +45,7 @@ class ncppplot {
const notcurses* notc = ncplane_notcurses(n);
ncblitter_e blitter = opts ? opts->gridtype : NCBLIT_DEFAULT;
if(blitter == NCBLIT_DEFAULT){
if(notcurses_canutf8(ncplane_notcurses(n))){
blitter = NCBLIT_8x1;
}else{
blitter = NCBLIT_1x1;
}
blitter = ncplot_defblitter(notc);
}
bool degrade_blitter = !(opts && (opts->flags & NCPLOT_OPTION_NODEGRADE));
auto bset = lookup_blitset(&notc->tcache, blitter, degrade_blitter);

Loading…
Cancel
Save