|
List Info
Thread: fun with backreferences
|
|
| fun with backreferences |

|
2006-05-19 07:05:59 |
The font configuration section of xorg shows a sed that
clobbers
Bitstream Vera fonts. While DejaVu is clearly preferred, do
we want to
remove the references to Bitstream?
I've been playing around with sed and came up with this:
sed -i \
's,\(^\t\t*\)\(<family>Bitstream
Vera\)\(.*\),\1<family>DejaVu\3\n\1\2\3,' \
fonts.conf
which produces a diff like this:
+ <family>DejaVu Serif</family>
<family>Bitstream Vera
Serif</family>
The 1st reference required a * because some of the lines
began with 3
tabs instead of 2. I'm no regex master, so perhaps this can
be shortened
by someone better than me (assuming the results are even
desired).
--
Archaic
Want control, education, and security from your operating
system?
Hardened Linux From Scratch
http://www.linux
fromscratch.org/hlfs
--
http://linuxfromscratch.org/mailman/listinfo/blfs-dev
FAQ: http://
www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page
|
|
| fun with backreferences |

|
2006-05-19 07:33:03 |
On Fri, May 19, 2006 at 01:05:59AM -0600, Archaic wrote:
> The font configuration section of xorg shows a sed that
clobbers
> Bitstream Vera fonts. While DejaVu is clearly
preferred, do we want to
> remove the references to Bitstream?
>
> I've been playing around with sed and came up with
this:
>
> sed -i \
> 's,\(^\t\t*\)\(<family>Bitstream
Vera\)\(.*\),\1<family>DejaVu\3\n\1\2\3,' \
> fonts.conf
>
> which produces a diff like this:
>
> + <family>DejaVu
Serif</family>
> <family>Bitstream Vera
Serif</family>
>
> The 1st reference required a * because some of the
lines began with 3
> tabs instead of 2. I'm no regex master, so perhaps
this can be shortened
> by someone better than me (assuming the results are
even desired).
Excuse the lack of quoting, but I'm CC'ing Alex since he
might not be
reading the lists right now and I want to be sure I'm
staying within the
desired final results.
Anyway, I found a problem with the sed for Arphic fonts as
well (both in
the wiki and in the livecd Makefile). Again, the tab count
might be 2 or
3, so I'm using this similar sed::
sed -i
's,\(^\t\t*\)\(<family>Kochi.*\),\1\2\n\1&l
t;family>AR PL New Sung</family>,'
--
Archaic
Want control, education, and security from your operating
system?
Hardened Linux From Scratch
http://www.linux
fromscratch.org/hlfs
--
http://linuxfromscratch.org/mailman/listinfo/blfs-dev
FAQ: http://
www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page
|
|
| fun with backreferences |

|
2006-05-19 08:03:51 |
Archaic wrote:
> On Fri, May 19, 2006 at 01:05:59AM -0600, Archaic
wrote:
>> The font configuration section of xorg shows a sed
that clobbers
>> Bitstream Vera fonts. While DejaVu is clearly
preferred, do we want to
>> remove the references to Bitstream?
>>
>> I've been playing around with sed and came up with
this:
>>
>> sed -i \
>> 's,\(^\t\t*\)\(<family>Bitstream
Vera\)\(.*\),\1<family>DejaVu\3\n\1\2\3,' \
>> fonts.conf
>>
>> which produces a diff like this:
>>
>> + <family>DejaVu
Serif</family>
>> <family>Bitstream Vera
Serif</family>
If you really want to have both fonts, please swap them
(i.e.: Bitstream should
come first, otherwise it would never be used if not
explicitly asked for). On
the CD, however, the intention is to clobber Bitstream Vera
because it is not
installed at all.
OTOH, DejaVu contains all characters originally present in
Bitstream fonts, and
it is a bug if these common characters render differently.
So, Bitstream fonts
are needed only for broken applications that explicitly ask
for them.
> Anyway, I found a problem with the sed for Arphic fonts
as well (both in
> the wiki and in the livecd Makefile). Again, the tab
count might be 2 or
> 3, so I'm using this similar sed::
>
> sed -i
's,\(^\t\t*\)\(<family>Kochi.*\),\1\2\n\1&l
t;family>AR PL New Sung</family>,'
The intention is to replace only inside <prefer> tags,
not in plain <alias>
tags, because it is stupid to assign both
"monospace" and "serif" aliases for
the same font (this would mean: if a character isn't
covered by AR PL New Sung,
search other serif fonts, oh no, search monospace fonts).
But it is OK to use
the same font when one asks for Chinese character in a
generic "monospace" and
"serif" families, because the screen resolution
is not sufficient to
distinguish. Thus, the replacement happens only in three-tab
lines.
As for the "after Kochi" placement, it's a
hack. The real intention for the
LiveCD is "before any other Chinese fonts".
--
Alexander E. Patrakov
--
http://linuxfromscratch.org/mailman/listinfo/blfs-dev
FAQ: http://
www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page
|
|
| fun with backreferences |

|
2006-05-19 13:15:15 |
On 5/19/06, Archaic <archaic linuxfromscratch.org>
wrote:
> The font configuration section of xorg shows a sed that
clobbers
> Bitstream Vera fonts. While DejaVu is clearly
preferred, do we want to
> remove the references to Bitstream?
Sort of. DejaVu is Bitstream Vera but with more characters.
It would
be useless to have a generic reference to Bitstream if you
had DejaVu
installed. It would never get chosen on a generic name.
You don't lose anything by leaving Bitstream in there, but
you don't
gain anything.
Your sed looks nice, though. I thought
maybe it would be easier
with i commands, but the backreferences only work in s///
replacements.
--
Dan
--
http://linuxfromscratch.org/mailman/listinfo/blfs-dev
FAQ: http://
www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page
|
|
| fun with backreferences |

|
2006-05-19 13:05:43 |
Archaic wrote:
> The font configuration section of xorg shows a sed that
clobbers
> Bitstream Vera fonts. While DejaVu is clearly
preferred, do we want to
> remove the references to Bitstream?
>
> I've been playing around with sed and came up with
this:
>
> sed -i \
> 's,\(^\t\t*\)\(<family>Bitstream
Vera\)\(.*\),\1<family>DejaVu\3\n\1\2\3,' \
> fonts.conf
I don't have time this morning to check it out, but how
about:
sed -ir \
's,(^\t\t*)(<family>Bitstream
Vera)(.*),\1<family>DejaVu\3\n\1\2\3,' \
fonts.conf
or perhaps
'/(^\t\t*)Bitstream Vera(.*)/i\1DejaVu\3\n'
IIRC, -r or --regexp-extended means you don't need to \
parens.
-- Bruce
--
http://linuxfromscratch.org/mailman/listinfo/blfs-dev
FAQ: http://
www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page
|
|
| fun with backreferences |

|
2006-05-19 13:29:21 |
On 5/19/06, Bruce Dubbs <bruce.dubbs gmail.com> wrote:
> or perhaps
>
> '/(^\t\t*)Bitstream Vera(.*)/i\1DejaVu\3\n'
You need to match <family>Bitstream because there are
other parts of
the file that match <string>Bitstream that don't have
to do with the
generic names.
> IIRC, -r or --regexp-extended means you don't need to
\ parens.
Oh yeah. Thanks, Bruce. As a final fix, you don't need
the explicit
\t markers.
sed -ir 's/^(.*)(<family>Bitstream
Vera)(.*)/\1<family>DejaVu\3\n\1\2\3/'
/etc/fonts/fonts.conf
--
Dan
--
http://linuxfromscratch.org/mailman/listinfo/blfs-dev
FAQ: http://
www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page
|
|
[1-6]
|
|