c# - Bold a part of string in generated barcode -
i generating barcode image. barcode consists of few different values, such amount, length, width , m2. these numbers displaying below barcode summary of user entries. there way either bold or underline m2 (square meters) in summary under barcode? please see below sample of needed:
here's code use generate barcode:
private void generate_click(object sender, eventargs e) { string barcode = summary.text; bitmap bitmap = new bitmap(barcode.length * 40, 150); using (graphics graphics = graphics.fromimage(bitmap)) { font ofont = new system.drawing.font("idautomationhc39m", 20); pointf point = new pointf (2f, 2f); solidbrush black = new solidbrush(color.black); solidbrush white = new solidbrush(color.white); graphics.fillrectangle(white, 0, 0, bitmap.width, bitmap.height); graphics.drawstring("*" + barcode + "*", ofont, black, point); } using (memorystream ms = new memorystream()) { bitmap.save(ms, imageformat.png); box4.image = bitmap; box4.height = bitmap.height; box4.width = bitmap.width; } }
you can use constructor of font
accepts font style (docs)
new system.drawing.font("idautomationhc39m", 20, fontstyle.bold);
the problem comes in determining part of text should bold means have split text @ point, , ascertain offset of bold text
since font you're using (idautomationhc39m
), renders bar code also, won't work unless find different font allow render bars separately text. leaves few options.
- separate fonts
- don't make text want bold
- make stand out in different way, colour text in different colour make stand out / draw line under / etc
Comments
Post a Comment